home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / applic / ntp / kent.shar / seq_nocase.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-29  |  725 b   |  26 lines

  1. /* seq_nocase: */
  2. /* perform case-insensitive comparison of null-terminated ASCII strings */
  3. /* return 0 if not equal, 1 if equal */
  4. /* BUG: shows a match when one string terminates as a subset of another, */
  5. /* but this doesn't affect usability in this context */
  6.  
  7. int seq_nocase (str1, str2)
  8. char *str1, *str2;
  9. {
  10.     char cv1, cv2;
  11.  
  12.     for ( ; ((*str1 != '\0') && (*str2 != '\0')); str1++, str2++)
  13.     {
  14.         cv1 = ((*str1 >= 'a') && (*str1 <= 'z')) ?
  15.           (0X7F & (*str1 - ('a' - 'A'))) : *str1;
  16.         cv2 = ((*str2 >= 'a') && (*str2 <= 'z')) ?
  17.           (0X7F & (*str2 - ('a' - 'A'))) : *str2;
  18.         if (cv1 != cv2)
  19.         {       /* chars unequal */
  20.                   return (0);
  21.         }
  22.     }
  23.     /* if we get here, all characters were equal */
  24.     return (1);
  25. }
  26.